/*
 * @: 异步并行钩子
 * @Version: 1.0
 * @Autor: ziwei
 * @Date: 2021-06-28 09:26:41
 * @LastEditors: ziwei
 * @LastEditTime: 2022-02-11 14:22:55
 */
const { AsyncParallelHook } = require('tapable');
const hook = new AsyncParallelHook(['name', 'age']);
console.time('cost');

debugger
hook.tapAsync('1',(name,age,callback)=>{
  setTimeout(()=>{
    console.log(1,name,age);
    callback()
  },1000)
})
hook.tapAsync('2',(name,age,callback)=>{
  setTimeout(()=>{
    console.log(2,name,age);
    callback()
  },2000)
})
hook.tapAsync('3',(name,age,callback)=>{
  setTimeout(()=>{
    console.log(1,name,age);
    callback()
  },3000)
})
debugger
hook.callAsync('zhufeng',12,(err)=>{
  console.log(err);
  console.timeEnd('cost');
})
